import React from "react";
import {
    BrowserRouter as Router,
    Switch,
    Route,
    Link,
    Redirect
} from 'react-router-dom';

function RouteWithSubRoutes(route) {
    return (
        <Route
            path={route.path}
            render={props => (
                // pass the sub-routes down to keep nesting
                <route.component {...props} routes={route.routes}/>
            )}
        />
    );
}


function renderLinkList (route) {
    return  <li className="list-group-item">
        <Link to={route.path}>{route.title}</Link>
    </li>
}

export {
    Router,
    Switch,
    Link,
    Route,
    RouteWithSubRoutes,
    renderLinkList,
    Redirect
}